package com.soulapp.hook.hooker

import android.content.Context
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
import com.soulapp.data.ConfigData

abstract class BaseHooker : YukiBaseHooker() {

    var hookEnabled: Boolean
        get() {
            return ConfigData.getBoolean(getKey())
        }
        set(value) {
            ConfigData.putBoolean(getKey(), value)
            if (value) startHook() else stopHook()
        }

    // 配置文件key
    abstract fun getKey(): PrefsData<Boolean>

    override fun onHook() {

    }

    // 开始hook
    abstract fun startHook()

    // 停止hook
    abstract fun stopHook()

    // 菜单item点击事件
    open var clickListener: ((context: Context) -> Unit)? = null
}